home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / picture / ring.c < prev    next >
Text File  |  1993-09-23  |  910b  |  49 lines

  1. //    Copyright 1993 Ralph Gonzalez
  2.  
  3. /*
  4. *    FILE:        ring.c
  5. *    AUTHOR:        R. Gonzalez
  6. *    CREATED:    October 8, 1990
  7. *
  8. *    defines methods for ring nested segment
  9. */
  10.  
  11. # include    "ring.h"
  12. # include    "trans.h"
  13. # include    "cube.h"
  14.  
  15. # define    NUM_CUBES    8
  16. # define    RADIUS        3.
  17. # define    CUBE_TYPE    Fast_Cube
  18.  
  19. /******************************************************************
  20. *    initialize
  21. ******************************************************************/
  22. Ring::Ring(void)
  23. {
  24.     int                i;
  25.     Translation        *transl;
  26.     Rotation_Y        *roty;
  27.     Transformation    *combination;
  28.     
  29.     transl = new Translation;
  30.     transl->set(-.5,-.5,RADIUS-.5);
  31.     roty = new Rotation_Y;
  32.     combination = new Transformation;
  33.     
  34.     num_segments = NUM_CUBES;
  35.     
  36.     for (i=0 ; i<NUM_CUBES ; i++)
  37.     {
  38.         segment[i] = new CUBE_TYPE;
  39.         roty->set(i*2.*PI/NUM_CUBES);
  40.         combination->combine(transl,roty);
  41.         segment[i]->move(combination);
  42.     }
  43.     
  44.     delete transl;
  45.     delete roty;
  46.     delete combination;
  47. }
  48.  
  49.